package top.serms.leetcode;

public class LeetCode_moveZeroes {

    public static void main(String[] args) {
        int[] nums = {1, 1, 0, 3, 12};
        moveZeroes(nums);
        for (int num : nums) {
            System.out.print(num + " ");
        }
    }


    public static void moveZeroes(int[] nums) {
        int slow = 0;
        for (int fast = 1; fast < nums.length; fast++) {
            if (nums[fast] != 0) {
                int tmp = nums[fast];
                nums[fast] = nums[slow];
                nums[slow++] = tmp;
            }
        }
    }

}
